/**
 * 音符音乐
 * @author 张勇 41204@qq.com
 * @date 2022-04
 */
 
#include <stdlib.h>
#include "notes_music.h"

const Note notes_music_1234567654321[] = {
	{TM1, B12}, {TM2, B12}, {TM3, B12}, {TM4, B12},
	{TM5, B12}, {TM6, B12}, {TM7, B12}, {TM6, B12},
	{TM5, B12}, {TM4, B12}, {TM3, B12}, {TM2, B12}, {TM1, B1},
	{TONE_MAX, BEAT_MAX}
};

// 上升
const Note notes_music_up2[] = {
	{TH1, B12},	{TH5, B1},
	{TONE_MAX, BEAT_MAX}
};

// 下降
const Note notes_music_down2[] = {
	{TH5, B12},	{TH1, B1},
	{TONE_MAX, BEAT_MAX}
};

const Note notes_music_up3[] = {
	{TH1, B12}, {TH3, B12}, {TH5, B1},
	{TONE_MAX, BEAT_MAX}
};

const Note notes_music_down3[] = {
	{TH5, B12}, {TH3, B12}, {TH1, B1},
	{TONE_MAX, BEAT_MAX}
};

const Note notes_music_didi[] = {
	{TH7, B12}, {TMT, B14}, {TH7, B12},
	{TONE_MAX, BEAT_MAX}
};

// 儿歌《小星星》
const Note notes_music_little_stars[] = {
	{TM1, B1}, {TM1, B1}, {TM5, B1}, {TM5, B1},  {TM6, B1},  {TM6, B1}, {TM5, B2},				// 一闪一闪亮晶晶
	{TM4, B1}, {TM4, B1}, {TM3, B1}, {TM3, B12}, {TM3, B12}, {TM2, B1},	{TM2, B1}, {TM1, B2},	// 满天都是小星星
	{TONE_MAX, BEAT_MAX}
};

// 儿歌《劳动最光荣》
const Note notes_music_sunlight[] = {
	{TM5, B14}, {TM3, B14}, {TM5, B14}, {TM3, B14}, {TH1, B14}, {TM6, B14}, {TM5, B2},
	{TM3, B14}, {TM1, B14}, {TM3, B14}, {TM1, B14}, {TM5, B14}, {TM3, B14}, {TM2, B2},
	{TONE_MAX, BEAT_MAX}
};

bool note_validate(const Note *note) {
	return note && note->tone < TONE_MAX && note->beat < BEAT_MAX;
}

const Note* note_next(const Note *notes) {
	return (note_validate(notes) && note_validate(notes+1)) ? (notes + 1) : NULL;
}
